package com.kolon.framework.interfaces;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;


@SuppressWarnings("rawtypes")
public class AbstractDao extends SqlSessionDaoSupport implements Dao {
	
	/**
	 * 목록 조회
	 */
	public List getList(String qry, Map args) throws SQLException {
		return (List)getSqlSession().selectList(qry, args);
	}
	
	/**
	 * 페이징 목록 조회
	 */
	public List getPageList(String qry, Map args, int startIndex, int endIndex) throws SQLException {
		RowBounds rowBounds = new RowBounds(startIndex, endIndex);
		return (List)getSqlSession().selectList(qry, args, rowBounds);
	}
	
	/**
	 * 총 수
	 */
	public int getCount(String qry, Map args) throws SQLException {
		return (Integer)getSqlSession().selectOne(qry, args);
	}	
	
	/**
	 * 상세 조회
	 */
	public Map getMap(String qry, Map args) throws SQLException {
		return (Map)getSqlSession().selectOne(qry, args);
	}

	/**
	 * 등록
	 */
	public int insert(String qry, Map args) throws SQLException {
		return getSqlSession().insert(qry, args);
	}
	
	/**
	 * 수정
	 */
	public int update(String qry, Map args) throws SQLException {
		return getSqlSession().update(qry, args);
	}
	
	/**
	 * 삭제
	 */
	public int delete(String qry, Map args) throws SQLException {
		return getSqlSession().delete(qry, args);
	}
	
}
